########################################################################
# localparms.py - Overrides Parameters class to add ddup-specific
#	things.
#
# Created 2006.08.30 by Warren Young
#
# Copyright (c) 2006 by Pixel Corps.  This program may be used under
# the terms of the X11 license, a copy of which should have accompanied
# this program, in the LICENSE file.
########################################################################

import parms

import os

class LocalParameters(parms.Parameters):
	"""
	wickddup-specific override of L{parms.Parameters}. Adds things
	specific to this program, and preprocesses some parameters in ways
	that make particular sense for this program.
	"""

	def __init__(self):
		"""
		Load parameters file, and preprocess it for wickddup's purposes.
		"""
	
		parms.Parameters.__init__(self, 'ddup')
		self.programName = '%s Uploader' % self['SystemShortName']

		# Rearrange FileNameCheck* parameters into ordered lists.  If
		# the number of the types of parameters is uneven, the lists
		# will be as long as the shortest parameter list.
		self.fileNameCheckLabels = []
		self.fileNameCheckLiteralRules = []
		self.fileNameCheckREs = []
		self.fileNameCheckWidths = []
		try:
			for i in range(1, 8):		# limit keeps GUI size sane
				label = self['FileNameCheck%dLabel' % i]
				rule = self['FileNameCheck%dLiteral' % i]
				regex = self['FileNameCheck%dRegex' % i]
				width = int(self['FileNameCheck%dWidth' % i])

				if label and rule and regex and width:
					self.fileNameCheckLabels.append(label)
					self.fileNameCheckLiteralRules.append(rule)
					self.fileNameCheckREs.append(regex)
					self.fileNameCheckWidths.append(width)
		except:
			pass


	def FileNameChecks(self):
		"""
		Returns the number of fully-defined file name checks. Actually
		returns the length of the Width list, because that one is
		appended to last, so it will always be the shortest if there is
		a mismatch in the list lengths.

		@rtype: integer
		@return: number of file name checks defined
		"""
		return len(self.fileNameCheckWidths)


parms = LocalParameters()

